﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using ECCIT;
using OgilvyOne.UKNow.BLL;
using OgilvyOne.UKNow.Globalization;
using ECCIT.Utilities;

public partial class GateService_ArtFormGate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.ContentType = "text/xml";
        Response.ContentEncoding = Encoding.UTF8;

        string output = string.Empty;
        try
        {
            ResultInfo valRes = ValidateArguments();

            if (valRes.Result)
            {
                string sLangID = Request.Params["lang"];
                string op = Request.Params["op"];

                int langID = (string.IsNullOrEmpty(sLangID)) ? 2052 : int.Parse(sLangID);
                ArtFormBLL bll = new ArtFormBLL(langID);

                switch (op)
                {
                    case "getArtForm":
                        string sID = Request.Params["id"];
                        output = JsonUtil.Serialize(bll.GetArtFormModelByID(int.Parse(sID)));
                        break;
                    case "getArtForms":
                        output = JsonUtil.Serialize(bll.GetArtFormModels());
                        break;
                }
            }
        }
        catch (Exception ex)
        {
            output = "<files value=\"false\"></files>";
        }

        Response.Write(output);
    }

    private ResultInfo ValidateArguments()
    {
        ResultInfo result = new ResultInfo(false);
        string sLangID = Request.Params["lang"];
        if (string.IsNullOrEmpty(sLangID)) return result;

        int langID;
        bool b = int.TryParse(sLangID, out langID);
        if (!b) return result;
        if (langID != 2052 && langID != 1033) return result;

        result.Result = true;
        return result;
    }
}